package com.iflytek.universitymanagement.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.iflytek.universitymanagement.domain.TutoringPlan;
import com.iflytek.universitymanagement.domain.TutoringPlanWithStudentName;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TutoringPlanMapper extends BaseMapper<TutoringPlan> {

    @Select("SELECT tp.plan_id, tp.student_id, tp.plan_name, tp.goal, tp.progress, tp.start_date, tp.end_date, s.name AS studentName " +
            "FROM tutoring_plan tp " +
            "JOIN student s ON tp.student_id = s.student_id")
    List<TutoringPlanWithStudentName> getTutoringPlansWithStudentNames();

    // 自定义查询：根据学生ID和计划ID查找辅导计划
    @Select("SELECT * FROM tutoring_plan WHERE plan_id = #{planId} AND student_id = #{studentId}")
    TutoringPlan selectTutoringPlanByPlanIdAndStudentId(Integer planId, Integer studentId);
}
